long s;
main(n,a,v,i)
{
	for(gets(&n);~scanf("%d%d",&n,&a);printf("%d\n",s%a))
		for(s=i=0;i<n;scanf("%d",&v),s+=i++%2?0:v);
}
